package com.xueyi.system.inspection.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xueyi.system.inspection.domain.po.InspectionPo;
import com.xueyi.system.inspection.domain.query.InspectionQuery;
import com.xueyi.system.inspection.domain.dto.InspectionDto;
import com.xueyi.system.inspection.mapper.InspectionMapper;
import com.xueyi.system.inspection.service.IInspectionService;
import com.xueyi.system.inspection.manager.IInspectionManager;
import com.xueyi.common.web.entity.service.impl.BaseServiceImpl;
import com.xueyi.system.productDetection.domain.po.ProductDetectionPo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 田间巡检管理 服务层处理
 *
 * @author zlf
 */
@Service
public class InspectionServiceImpl extends BaseServiceImpl<InspectionQuery, InspectionDto, IInspectionManager> implements IInspectionService {


    @Autowired
    private InspectionMapper inspectionMapper;
    /**
     * 查询田间巡检对象列表 | 数据权限 | 附加数据
     *
     * @param inspection 田间巡检对象
     * @return 田间巡检对象集合
     */
    @Override
    //@DataScope(userAlias = "createBy", mapperScope = {"InspectionMapper"})
    public List<InspectionDto> selectListScope(InspectionQuery inspection) {
        return baseManager.selectListExtra(inspection);
    }

    @Override
    public List<InspectionPo> findByList(String plantId) {
        QueryWrapper<InspectionPo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("plant_id",plantId);
        queryWrapper.eq("type",3);
        queryWrapper.orderByAsc("inspection_time");
        List<InspectionPo> inspectionPoList = inspectionMapper.selectList(queryWrapper);
        return inspectionPoList;
    }
}
